package com.example.springtask.bean;

import org.springframework.cloud.task.listener.annotation.AfterTask;
import org.springframework.cloud.task.listener.annotation.BeforeTask;
import org.springframework.cloud.task.listener.annotation.FailedTask;
import org.springframework.cloud.task.repository.TaskExecution;
import org.springframework.stereotype.Component;

@Component
public class MyBean {

    @BeforeTask
    public void methodA(TaskExecution taskExecution) {
        System.out.println("methodA:"+taskExecution.getTaskName());
    }

    @AfterTask
    public void methodB(TaskExecution taskExecution) {
        System.out.println("methodB:"+taskExecution.getExecutionId());
        //taskExecution.setExitMessage("AFTER EXIT MESSAGE");
    }

    @FailedTask
    public void methodC(TaskExecution taskExecution, Throwable throwable) {
        System.out.println("methodC:"+taskExecution.getExecutionId());
    }
}